


<?php
/* http://192.168.1.175/jsonApi/api/login.php?ln=jack&pwd=123 */
/* http://localhost/jsonApi/api/login.php?ln=jack&pwd=123 ,$password*/

include_once '../include/user.inc.php';
include_once '../model/user.class.php';
include_once '/shared/common.inc.php';

try {
	$logName = G('ln');
	$password = G('pwd');
	
	if(!empty($logName)&& !empty($password)){
		$md5_pwd = md5(utf8_encode($password));
		$loginUser = new User($logName,$md5_pwd);
		$login_result = UO::login($loginUser);
		
		if($login_result == 1){
			$loginUser = UO::getUserInfo($loginUser,'loginInfo');
			$arrState = array('nn'=>$loginUser->nickName,'uid'=>$loginUser->uid,'logState'=>$login_result);
		} else {
			$arrState = array('logState'=>$login_result);
		}
		
	} else {
		$arrState = array('logName'=>$logName,'logState'=>-1);
	}

	echo json_encode($arrState);
}
catch (Exception $ex){
	echo json_encode(array('code'=>$ex->getCode(),'msg'=>$ex->getMessage()));
}

?>